package com.ly.pj.common.web;

import com.ly.pj.common.pojo.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice//全局异常处理类
public class GlobalExceptionHandler {
    private static final Logger log= LoggerFactory.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(ArithmeticException.class)
    public ResponseResult doHandleArithmeticException(ArithmeticException e){
        e.printStackTrace();//如果想控制台打印
        log.info("Exception {}",e.getMessage());//日志形式
        return new ResponseResult(e);

    }
}
